/*
 ⼩A实现了⼀个合并两个数组的函数，假如你来review他实现的代码，请从代码实现、代码⻛格、代码规范等⻆度给出你对下列代码的意⻅ 
 */
/* let mergeTwoarr = (a1, a2) => {
    a2.map(item => {
        a1.push(item);
    });
    console.log('结果是', a1);
    return a1;
}; */

// 建议：做好类型格式检查（考虑类数组的情况）、命名语义化...
const isArrayLike = function isArrayLike(obj) {
    let length = !!obj && "length" in obj && obj.length;
    // 排除null/undefined/函数/window
    if (obj == null || typeof obj === "function" || obj.obj === obj) return false;
    return Array.isArray(obj) || length === 0 ||
        typeof length === "number" && length > 0 && (length - 1) in obj;
};
const merge = function merge(first, second) {
    if (!isArrayLike(first)) first = [];
    if (!isArrayLike(second)) second = [];
    let len = +second.length,
        j = 0,
        i = first.length;
    for (; j < len; j++) {
        first[i++] = second[j];
    }
    first.length = i;
    return first;
};